<template>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      :visible.sync="visible"
      :before-close="cancel"
      class="JNPF-dialog JNPF-dialog_center"
      lock-scroll
      width="50%"
    >
      <el-row :gutter="15" class="">
        <el-form
          ref="elForm"
          :model="dataForm"
          :rules="rules"
          label-width="100px"
        >
          <el-col :span="12">
            <el-form-item label="试剂编号" class="required" prop="FCATNO">
              <el-input
                v-model="dataForm.FCATNO"
                placeholder="请输入"
                clearable
                :disabled="!insertorupdate"
                maxlength="8"
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item class="required" label="中文别名" prop="FALIAS">
              <el-input
                v-model="dataForm.FCATNAME"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item class="required" label="试剂品名" prop="FCATNAME">
              <el-input
                v-model="dataForm.FCATNAME"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item class="required" label="英文别名" prop="FENGNAME">
              <el-input
                v-model="dataForm.FCATNAME"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="CAS号">
              <el-input
                v-model="dataForm.FCAS"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>
         
          <el-col :span="12">
            <el-form-item label="形态">
              <el-select v-model="dataForm.FTYPE" placeholder="请选择" >
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="密度">
              <el-input
                v-model="dataForm.FSIZE"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="状态">
              <el-select v-model="dataForm.FSTATE" placeholder="请选择" >
                <el-option
                  v-for="item in options5"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="库存单位">
              <el-input
                v-model="dataForm.FUNIT"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="换算系数">
              <el-input
                v-model="dataForm.FPACK"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="采购单位">
              <el-input
                v-model="dataForm.FORDUNIT"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="采购系数">
              <el-input
                v-model="dataForm.FORDPACK"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="保质期">
              <el-input
                v-model="dataForm.FSAFEDAY"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="安全库存">
              <el-input
                v-model="dataForm.FSAFEQTY"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="试剂分类">
              <el-select v-model="dataForm.FCLASS" placeholder="请选择" >
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="试剂属性">
              <el-select v-model="dataForm.FFLAG" placeholder="请选择" >
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="冲突试剂">
              <el-select v-model="dataForm.FOTHER" placeholder="请选择" >
                <el-option
                  v-for="item in options4"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="其他描述">
              <el-input
                v-model="dataForm.FMEMO"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button  v-if="insertorupdate" type="primary" v-loading="loading">确 定</el-button>
        <el-button v-else type="primary"  v-loading="loading">修 改</el-button>
      </span>
    </el-dialog>
  </template>
  <script>
  import jnpf from "@/utils/jnpf"
  export default {
    props: {
      parelist: {
        type: Array,
        default: []
      },
    },
    data() {
      return {
          title:"新增",
          dataForm:{
            FCATNO:"700001"
            ,FCATNAME:"甲酸乙烯酯"
            ,FTYPE:"液体(毫升)"
            ,FSEQNO:""
            ,FVISIBLE:1
            ,FCAS:"692-45-5"
            ,FCLASS:"一般化学品"
            ,FSIZE:"0 克/毫升"
            ,FSTATE:"正常"
            ,FUNIT:"克"
            ,FPACK:6000
            ,FORDUNIT:"箱"
            ,FORDPACK:1
            ,FSAFEDAY:0
            ,FSAFEQTY:6000
            ,FOPERATOR:""
            ,FUPDDATE:jnpf.dateFormat(new Date(),"YYYY-MM-DD")
          },
          rules: {
            FCATNO: [
                  { required: true, message: '请输入试剂编号', trigger: 'blur' },
              ],
              FCATNAME: [
                  { required: true, message: '请输入试剂名称', trigger: 'blur' },
              ],
              FCAS: [
                  { required: true, message: '请输入CAS', trigger: 'blur' },
              ],
          },

        options1: [{
          value: '1',
          label: '固态'
        }, {
          value: '2',
          label: '液态'
        }],

        options2: [{
          value: '1',
          label: '易制毒'
        }, {
          value: '2',
          label: '易制爆'
        }, {
          value: '3',
          label: '一般化学品'
        }, {
          value: '4',
          label: '剧毒品'
        }, {
          value: '5',
          label: '危险化学品'
        }],

        options3: [{
          value: '1',
          label: '急性毒性,类别1、类别2、类别3 - 有机'
        }, {
          value: '2',
          label: '急性毒性,类别1、类别2、类别3 - 无机'
        }, {
          value: '3',
          label: '金属腐蚀物,皮肤腐蚀/刺激,类别1 - 碱性有机'
        }],

        //冲突试剂
        options4: [{
          value: '1',
          label: '氨酚氢可酮片'
        }, {
          value: '2',
          label: '纳布啡及其注射剂'
        }, {
          value: '3',
          label: '呋芬雷司'
        }],

        options5: [{
          value: '1',
          label: '正常'
        }, {
          value: '2',
          label: '删除'
        }],

        loading:false,
        visible:false,
        insertorupdate:true
      };
    },
    created() {
    },
    mounted() {},
    methods: {
      //
      init(id){
        this.dataForm.FCATNO= id || ''
          if(this.dataForm.FCATNO)
          {
              this.title="修改"
             this.insertorupdate=false;
          }
          else
          {
            this.insertorupdate=true;
              this.title="新增";
          }
          this.visible=true;
      },
      //
      cancel(){
          this.$refs.elForm.resetFields();
          this.visible=false;
      },
    },
  };
  </script>
  
  
  
  
  